# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=npm-check-updates
pkgdesc='Find newer versions of dependencies than what your package.json or bower.json allows'
pkgver=16.14.9
pkgrel=1
arch=('any')
url='https://github.com/tjunnone/npm-check-updates'
license=('Apache')
depends=('nodejs-nopt' 'npm' 'semver')
makedepends=('git')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('7ee5b8dcd709ec33114c352e9c5bc9799690c5baeb7a62307a491d6b277f007c0251faf64cbbc301e936e25293081d0be892f6567cc6695e8e5bc2d756a513d3')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Experimental dedup
  rm -r "$pkgdir"/usr/lib/node_modules/$pkgname/node_modules/{,.bin/}nopt
  rm -r "$pkgdir"/usr/lib/node_modules/$pkgname/node_modules/{,.bin/}semver

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"
}
